import { createApp } from 'vue';
import website from './config/website';
import axios from './axios';
import router from './router/';
import store from './store';
import i18n from './lang/';
import { language, messages } from './lang/';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
import crudCommon from '@/mixins/crud.js';
import { getScreen,toFixed, currencyFilter } from './utils/util';
import './permission';
import error from './error';
import avueUeditor from 'components/avue-ueditor/main.vue';
import basicBlock from 'components/basic-block/main.vue';
import basicContainer from 'components/basic-container/main.vue';
import thirdRegister from './components/third-register/main.vue';
// import NfDesignBase from '@saber/nf-design-base-elp';
// import NfDesignBase from '@xtkj/sd-base';
import flowDesign from './components/flow-design/main.vue';
// import FilterInput from 'components/vxe-filters/FilterInput.vue'
// import FilterContent from 'components/vxe-filters/FilterContent.vue'
// import FilterComplex from 'components/vxe-filters/FilterComplex.vue'

import App from './App.vue';
import 'animate.css';
import dayjs from 'dayjs';
import 'styles/common.scss';
// 业务组件
import tenantPackage from './views/system/tenantpackage.vue';

// 自定义组件
import Empty from 'components/empty/main.vue';
import Upload from 'components/upload/main.vue';
import Wangeditor from 'components/wangeditor/main.vue';
import Modal from 'components/modal/main.vue';
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import VXETablePluginElement from 'vxe-table-plugin-element'
import 'vxe-table-plugin-element/dist/style.css'
import VxeUI from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import Slider from 'components/slider/main.vue';
import BasicTable from 'components/basic-table/main.vue';
import FormSearch from 'components/FormSearch/index.vue';
import preview from 'components/preview/main.vue';
import numberRange from 'components/number-range/main.vue';

import directive from './directive' // directive

import "./components/vxe-edit/index"
import "./components/vxe-filters/index"
// 富文本注册
import { Boot } from '@wangeditor/editor';
import attachmentModule from '@wangeditor/plugin-upload-attachment';
Boot.registerModule(attachmentModule);

window.$crudCommon = crudCommon;
window.$globApi = import.meta.glob(`./api/**/**`, { eager: true }) ;
window.axios = axios;
const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
// app.component('FilterInput', FilterInput);
// app.component('FilterContent', FilterContent);
// app.component('FilterComplex', FilterComplex);
app.component('FormSearch', FormSearch);
app.component('avueUeditor', avueUeditor);
app.component('basicContainer', basicContainer);
app.component('basicBlock', basicBlock);
app.component('thirdRegister', thirdRegister);
app.component('flowDesign', flowDesign);
app.component('tenantPackage', tenantPackage);
app.component('empty', Empty);
app.component('upload', Upload);
app.component('wangeditor', Wangeditor);
app.component('modal', Modal);
app.component('slider', Slider);
app.component('basicTable', BasicTable);
app.component('preview', preview);
app.component('numberRange', numberRange)
app.config.globalProperties.$dayjs = dayjs;
app.config.globalProperties.website = website;
app.config.globalProperties.getScreen = getScreen;
app.config.globalProperties.$toFixed = toFixed;
app.config.globalProperties.currencyFilter = currencyFilter;
import mitt from 'mitt'
const emitter = mitt();
app.config.globalProperties.$emitter = emitter;

app.use(error);
app.use(i18n);
app.use(store);
app.use(router);
app.use(ElementPlus, {
  locale: messages[language],
});
app.use(VxeUI)
app.use(VXETable);
VXETable.use(VXETablePluginElement);
app.config.globalProperties.$VXETable = VXETable;


directive(app)

app.config.globalProperties.res = axios.defaults.baseURL + "/res";
// 键盘监听
app.config.globalProperties.$keyBoard = function (vm, methodName, code) {
    document.onkeydown = function () {
        let key = window.event.keyCode;
        if (key === code) {
            vm[methodName](code); // 触发methodName事件
        }
    };
}
app.use(Avue, {
  axios,
  calcHeight: 10,
  locale: messages[language],
});
// app.use(NfDesignBase);
// app.use(SelectTable);
app.mount('#app');
